<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>VUE第二天 生命周期钩子函数</title>
</head>
<body>
  <div id="app"> 
    <input type="text" v-model="info">
    <p>{{info}}</p>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        info: 'hello'
      },
      // 实例创建前
      beforeCreate() {
        console.log('111beforeCreate');
        console.log(this.$el);
        console.log(this.$data);
        console.log('111beforeCreate');
      },
      // 实例创建完成
      created() {
        console.log('222created');
        console.log(this.$el);
        console.log(this.$data);
        this.fn1();
        console.log('222created');
      },
      // 挂载前
      beforeMount() {
        console.log('beforeMount');
        console.log(this.$el);
        console.log(this.$data);
        console.log('beforeMount');
      },
      // 挂载后
      mounted() {
        console.log('mounted');
        console.log(this.$el);
        console.log(this.$data);
        console.log('mounted');
      },
      // 数据更新前
      beforeUpdate() {
        alert(6666)
        console.log('beforeUpdate');
        console.log(this.$el);
        console.log(this.$data);
        console.log('beforeUpdate');
      },
      // 数据更新后
      updated() {
        console.log('updated');
        console.log(this.$el);
        console.log(this.$data);
        console.log('updated');
      },
      // 实例销毁前
      beforeDestroy(){
        console.log('beforeDestroy');
        console.log(this.$el);
        console.log(this.$data);
        console.log('beforeDestroy');
      },
      // 实例销毁后
      destroyed(){
        console.log(this.$el);
        console.log(this.$data);
      },
      methods: {
        fn1() {
          console.log('=================',666);
        }
      },
    })
  </script>
</body>
</html>